package com.test.daily.leetcode.y2022.m06.day0616.v03;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/6/16 下午 09:47
 * @version: 1.0
 */
public class Solution {
    public int findPairs(int[] nums, int k) {
        Set<Integer> visited = new HashSet<>();
        Set<Integer> res = new HashSet<>();
        for (int num : nums) {
            if (visited.contains(num - k)) {
                res.add(num - k);
            }
            if (visited.contains(num + k)) {
                res.add(num);
            }
            visited.add(num);
        }
        return res.size();
    }
}
